 GetList1();
 window.setInterval(GetList1, 2000);
 /*自选*/
 function GetList1() {

 	$.get('http://liveapi.99990158.com/ajax/getmarketlistdata.aspx', {}, function(data) {
 		var obj = JSON.parse(data);
 		/*自选*/
 		SetUL('ullist0', obj.data.list);

 		var data1 = _.filter(obj.data.list, function(n) {
 			return n.productname.indexOf('美元') < 0&&n.productname.indexOf('伦敦') < 0;
 		});
 		/*上海黄金*/
 		SetUL('ullist1', data1);

 		var data2 = _.filter(obj.data.list, function(n) {
 			return n.productname.indexOf('伦敦') >= 0;
 		});
 		/*国际黄金*/
 		SetUL('ullist2', data2);

 		var data3 = _.filter(obj.data.list, function(n) {
 			return n.productname.indexOf('美元') >= 0;
 		});
 		/*美元*/
 		SetUL('ullist3', data3);
 	});
 }

 /*通过id 和数据 来构建页面html*/
 function SetUL(id, data) {
 	if(!id)
 		return;
 	var lis = [];
 	mui.each(data, function(index, item) {

 		var html = "";
 		html += '<li class="mui-table-view-cell" onclick="openMarket(\'' +item.productcode + '\',\''+item.productname+'\')">';

 		html += '<table class="hqtable">';
 		html += '<tr>';

 		html += '<td class="hqp1 mui-col-xs-6">';
 		html += '<h4>' + item.productname + '</h4>';
 		html += '<p class="hqp2">' + item.productcode + '</p>';
 		html += '</td>';

 		if(item.updown > 0) {
 			html += '<td class="hqp3 mui-col-xs-4 hqp r">' + item.newprice.toFixed(2) + '</td>';
 			html += '<td class="hqp4 mui-col-xs-4 hqp r">+' + (item.updownrate * 100).toFixed(2) + '%</td>';
 		} else {
 			html += '<td class="hqp3 mui-col-xs-4 hqp g">' + Math.abs(item.newprice.toFixed(2)) + '</td>';
 			html += '<td class="hqp4 mui-col-xs-4 hqp g">-' + Math.abs((item.updownrate * 100).toFixed(2)) + '%</td>';
 		}

 		html += '</tr>';
 		html += '</table>';

 		html += '</li>';

 		 
 		lis.push(html);
 	});
 	try {

 		var ullist1 = document.getElementById(id);

 		ullist1.innerHTML = lis.join(" ");
 		/*console.log(id);*/
 	} catch(e) {
 		//TODO handle the exception
 		console.log(e);
 	}

 }
 
 
function openMarket(productcode,productname){
	 
	openWindowWithTitle("marketView.html?code="+productcode,productname+'')
}
